package ar.com.fiuba.ElectronicCircuitAnalyst.domain.impl.functions.jeval;

import java.util.List;

import net.sourceforge.jeval.VariableResolver;
import net.sourceforge.jeval.function.FunctionException;

public class JevalVariableResolverImpl implements VariableResolver {
	public static final String TRUE = "1";
	public static final String FALSE = "0";
	
	private List<Boolean> values;
	
	public JevalVariableResolverImpl(List<Boolean> values){
		this.values = values;
	}
	public String resolveVariable(String inputName) throws FunctionException {
		return encodeValue(this.values.get(new Integer(inputName.replace("E", "")) - 1));
	}
	private String encodeValue(Boolean value){
		return value ? TRUE : FALSE;
	}
}
